package com.qf.common.common;

import lombok.Getter;

@Getter
public class R {
    private Integer code;
    private String msg;
    private Object data;

    public static R ok() {
        return new R(200, "成功");
    }

    public static R ok(Object data) {
        return new R(200, "成功", data);
    }

    public static R ok(Integer code, String msg) {
        return new R(code, msg);
    }

    public static R ok(Integer code, String msg, Object data) {
        return new R(code, msg, data);
    }

    public static R fail() {
        return new R(500, "失败");
    }

    public static R fail(Object data) {
        return new R(500, "失败", data);
    }

    public static R fail(Integer code, String msg) {
        return new R(code, msg);
    }

    public R() {
    }

    public R(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public R(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
